package nongchang.kuaijiecaifu.com.ncapp_android.ui;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ezy.lite.util.ContextUtil;
import ezy.widget.adapter.TabsAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.activity.BaseActivity;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.LifeShop;

import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.main.Link;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.adapter.LifeShopAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.lifeshopfragment.LifeShopDetailFragment;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.lifeshopfragment.LifeShopJoinFragment;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.lifeshopfragment.LifeShopRaffleFragment;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.widget.BannerLayout;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.widget.LoadingLayout;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.widget.OnLoadeMoreListener;

public class LifeShopActivity extends BaseActivity {
    @BindView(R.id.banner)
    BannerLayout bannerLayout;
    @BindView(R.id.orderby)
    TabLayout mTabOrderBy;
    @BindView(R.id.pager)
    ViewPager mViewPager;
    private LifeShopAdapter mlifeShopAdapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_life_shop);
        ButterKnife.bind(this);
        Link link = new Link();
        link.image = "http://www.kuaijiecaifu.com/uploads/banner/20160308/56de477d2e1b8.jpg";
        link.title = "我擦";
        link.url = "www.baidu.com";
        Link link1 = new Link();

        link1.image = "http://www.kuaijiecaifu.com/uploads/banner/20160307/56dd4a96b19fe.jpg";
        link1.title = "我擦";
        link1.url = "www.baidu.com";
        List<String> photoUrl = new ArrayList<>();
        photoUrl.add(link.image);
        photoUrl.add(link1.image);
        bannerLayout.setViewUrls(photoUrl);

//        mlifeShopAdapter = new LifeShopAdapter(this);
        Fragment fragments[]={new LifeShopDetailFragment(),new LifeShopRaffleFragment(),new LifeShopJoinFragment()};
        mViewPager.setAdapter(new TabsAdapter(getSupportFragmentManager(), fragments));
        mTabOrderBy.addTab(mTabOrderBy.newTab().setText("商品详情"), true);
        mTabOrderBy.addTab(mTabOrderBy.newTab().setText("晒单详情"));
        mTabOrderBy.addTab(mTabOrderBy.newTab().setText("参与记录"));
        mTabOrderBy.setOnTabSelectedListener(onTabSelectedListener);
        mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabOrderBy));
    }
    TabLayout.OnTabSelectedListener onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            mViewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    };
@OnClick({R.id.txt_gamerule})
    void onClick(View view){
    switch (view.getId()){
        case R.id.txt_gamerule:
            ContextUtil.startActivity(this,GameRuleActivity.class);
            break;
    }
}
}
